import MSProcessor
import time
import os

LOG_FILE = '/tmp/magic/ms.log'
STOP_FILE = '/tmp/magic/ms.stop'
RECONF_FILE = '/tmp/magic/ms.reconf'

MSProcessor.MSLogger.logInit(LOG_FILE, 2, False)
processor = MSProcessor.MSProcessor()
processor.readConfig('processor_x.cfg', 'objects.cfg')

while not os.path.isfile(STOP_FILE):
    try:
        processor.readEvents()
        processor.storeEvents()
        processor.dropQueues()
        time.sleep(10)
        
        if os.path.isfile(RECONF_FILE):
            processor.readConfig('processor_x.cfg', 'objects.cfg')
            os.unlink(RECONF_FILE)
        
    except (Exception), err:
        MSProcessor.MSLogger.logError('main: exception: %s' % str(err))

os.unlink(STOP_FILE)
